﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DynamicChart.Data
{
    /// <summary>
    /// 查询参数
    /// </summary>
    public class QueryParameter
    {
        public const string UserKey = "user";
        public const string OrgKey = "org";
        public const string StartDateKey = "startdate";
        public const string EndDateKey = "enddate";

        private Dictionary<string, string> _keyValues;

        public string User
        {
            get
            {
                return this[UserKey];
            }
            set
            {
                this[UserKey] = value;
            }
        }

        public string Org
        {
            get
            {
                return this[OrgKey];
            }
            set
            {
                this[OrgKey] = value;
            }
        }

        public string StartDate
        {
            get
            {
                return this[StartDateKey];
            }
            set
            {
                this[StartDateKey] = value;
            }
        }

        public string EndDate
        {
            get
            {
                return this[EndDateKey];
            }
            set
            {
                this[EndDateKey] = value;
            }
        }

        public string this[string key]
        {
            get
            {
                foreach(string item in _keyValues.Keys)
                {
                    if (item == key)
                    {
                        return _keyValues[item];
                    }
                }
                return string.Empty;
            }
            set
            {
                foreach(string item in _keyValues.Keys)
                {
                    if (item == key)
                    {
                        _keyValues[item] = value;
                        return;
                    }
                }
                _keyValues.Add(key, value);
            }
        }

        public QueryParameter()
        {
            _keyValues = new Dictionary<string, string>();
        }
    }
}
